import 'package:flutter/widgets.dart';
import 'package:netease_cloud_music_api/utils/crypto.dart';
import 'package:netease_cloud_music_api/utils/player_request.dart';
import 'package:netease_cloud_music_api/utils/request.dart';

mixin Batch {
  Future<PlayerRequestResponse> batch({required Map<String, dynamic> query}) {
    Map<String, dynamic> data = Map<String, dynamic>();
    query.forEach((key, value) {
      if (RegExp(r'\/api\/').hasMatch(key)) {
        data[key] = value;
      }
    });
    print(data);
    return PlayerRequest(
      url: 'http://music.163.com/eapi/batch',
      data: data,
      options: PlayerRequestOptions(
        method: PlayerRequestMethod.post,
        crypto: EncryptType.eapi,
        url: '/api/batch'
      ),
    ).request();
  }
}
